#ifndef COMMITTEEMANAGER_H
#define COMMITTEEMANAGER_H

#include <map>

#include "ISerializable.h"
#include "IStringRepresentable.h"
#include "Committee.h"

class CommitteeManager : public ISerializable, public IStringRepresentable
{
public:
  typedef std::map<std::string, Committee> CommitteeMap;
  typedef std::pair<std::string, Committee> CommitteePair;

  CommitteeManager()
  {    
  }

  virtual ~CommitteeManager()
  {
  }

  const CommitteeMap& committees() const { return m_committees; }
  const Committee *committeeById(const std::string &id) const;
  std::string newCommitteeId() const;
  virtual bool serialize(const std::string& fileName) const;
  virtual bool deserialize(const std::string& fileName);
  void clear() { m_committees.clear(); }
  virtual std::string toString() const;

  void insert(const Committee& committee)
  {
    m_committees[committee.id()] = committee;
  }

  int size() const { return static_cast<int>(m_committees.size()); }

private:
  void toStream(std::ostream& stream) const;

  CommitteeMap m_committees;
};

#endif // COMMITTEEMANAGER_H